const arr = [1, 2, 3, 4, 5, 6]

// let res = arr.map((item, index, arr) => {
//   return item * 2
// })

// console.log(res);   // [ 2, 4, 6, 8, 10, 12 ]

Array.prototype.myMap = function (callback) {
  let res = []
  for (let i = 0; i < this.length; i++) {
    res.push(callback(this[i], i, this))
  }
  return res
}

let res = arr.myMap((item, index, arr) => {
  return item * 2
})

console.log(res);

